/*
 * @Author: amy
 * @Date:   2019-07-03 16:37:29
 * @Last Modified by:   amy
 * @Last Modified time: 2019-07-03 17:03:09
 */
import BigIntModule from "@module/rsa/BigInt";
import RSA from "@module/rsa/RSA_Stripped";
export default {
	webencryptAES: function(str) {
		if (!str) return "";
		BigIntModule.setMaxDigits(130);
		var PublicExponent = "10001";
		var modulus =
			"8559775cc84ffc46d91f465a2edcc487e4e09f37343f6958878f2dee9a8b7a91a0aa6cc150282552b36523ee7a83d4f2229dace560e31f38423a8b00fdb82589b1c0f178f70e47029f3be074302e61cf83514c099794d7d306b6cf0388cb264af354e2e410e4dd40bae2804cfb1a8ca6c2109f2f683536e3d95aba0fed9ac829";
		var key = new RSA.RSAKeyPair(PublicExponent, "", modulus);
		var ramdomTxt = String(new Date().getTime());
		if (ramdomTxt.length > 8) {
			ramdomTxt = ramdomTxt.substring(ramdomTxt.length - 8);
		} else if (ramdomTxt.length < 8) {
			var lStr = "";
			for (var i = 0; i < 8 - ramdomTxt.length; i++) {
				lStr += "0";
			}
			ramdomTxt = lStr + ramdomTxt;
		}
		ramdomTxt += String(Math.ceil(Math.random() * 100000));
		return RSA.encryptedString(key, ramdomTxt + String(str));
	}
};
